package reports.dq;

import java.io.ByteArrayOutputStream;
import java.util.Date;

import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

import dinamica.*;

/**
 * Reporte PDF (IText) basico con logo, titulo, filtro de busqueda, tabla, 
 * total, grafico y pie de pagina hecho con codigo, con estilo "pagina X de Y". 
 * Para el manejo de los eventos que imprimen el pie de pagina, esta clase usa
 * una clase generica del framework llamada "PDFPageEvents". Puede proveer
 * su propio manejador de eventos si tiene necesidades mas elaboradas.
 * <br><br>
 * Actualizado: 2007-05-29<br>
 * Framework Dinamica - Distribuido bajo licencia LGPL<br>
 * @author mcordova (martin.cordova@gmail.com)
 */
public class JiupiaoPDFGenerator extends AbstractPDFOutput
{

	//页脚所需的参数
    PdfTemplate tpl = null;
    BaseFont bf = null;
    PdfContentByte cb = null;
    Image img = null;
    Font tblHeaderFont = null;
    Font tblBodyFont = null;
    
    //报告的页面参数（可更改部分）
    String reportTitle = ""; //从config.xml读默认值
    String reportSubTitle = ""; //从config.xml读值
    String footerText = ""; //从web.xml或confix.xml读取它的默认配置
    String logoPath = "/images/logo-dinamica.png"; //图标
    String pageXofY = " / ";  //默认文字页(第几页)X的Y
    
    @Override
    protected void createPDF(GenericTransaction data, ByteArrayOutputStream buf)
            throws Throwable
    {

		//inicializar documento: tamano de pagina, orientacion, margenes
    	//初始化文件：页面大小，边,边沿,边缘
		Document doc = new Document();
		PdfWriter docWriter = PdfWriter.getInstance(doc, buf);
		doc.setPageSize(PageSize.A4);
		doc.setMargins(30,30,30,40);
		
		doc.open();

		//crear fonts por defecto
		//字体(大小及风格)
		bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
		tblHeaderFont = new Font(bf, 18f, Font.BOLD);
		tblBodyFont = new Font(bf, 14f, Font.NORMAL);
		
		//definir pie de pagina del lado izquierdo
		//得到footerText,设置时间显示样式
		String footerText = this.getFooter(); //read it from config.xml or web.xml
		String reportDate = StringUtil.formatDate(new java.util.Date(), "yyyy-MM-dd");
		
		//create template (the subject of internal IText) and event handler
		//para imprimir el pie de pagina
		//bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
		cb = docWriter.getDirectContent();
		tpl = cb.createTemplate(20, 14);
		docWriter.setPageEvent(new PDFPageEvents(footerText, pageXofY, tpl, bf, cb, reportDate));

		//title - you read it in default config.xml
		reportTitle = getReportTitle();
		Paragraph t = new Paragraph(reportTitle, new Font(bf, 16f, Font.BOLD));
		t.setAlignment(Rectangle.ALIGN_CENTER);
		doc.add(t);

		//logo
		/*
		img = Image.getInstance(getImage(this.getServerBaseURL() + logoPath, false));
		img.scalePercent(100);
		float imgY = doc.top() - img.getHeight();
		float imgX = doc.left();
		img.setAbsolutePosition(imgX, imgY);
		*/
		//doc.add(img);	

		//阄票第一行
		PdfPTable jiuPiao = getDataTable(data);
		jiuPiao.setSpacingBefore(10f);
		doc.add(jiuPiao);


		
		//imprimir tabla de datos
		/*PdfPTable datatbl = getDataTable(data);
		datatbl.setSpacingBefore(10);
		doc.add(datatbl);*/

		//imprimir filtro de busqueda
		/*PdfPTable bottom = getReportBottom(data);
		bottom.setSpacingBefore(40);
		doc.add(bottom);*/

		doc.close();
		docWriter.close();
		
    }

	/**
	 * Retorna una tabla conteniendo el filtro de busqueda
	 * PDF
	 * @param data Objeto de negocios que suple los recordsets
	 * @return
	 */
	PdfPTable getDataTable(GenericTransaction data) throws Throwable
	{

		//obtener recordset de filtro
		Recordset rs = data.getRecordset("query.sql");
		rs.top();
		
		//definir estructura de la tabla
		PdfPTable datatable = new PdfPTable(26);
		datatable.getDefaultCell().setPadding(10);
		//datatable.getDefaultCell().setFixedHeight(20);
		datatable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
		datatable.getDefaultCell().setBorder(Rectangle.NO_BORDER);    //设置表格默认为无边框
		int headerwidths[] = {35,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20}; /*26个隔 共 320*/
		datatable.setWidths(headerwidths);
		datatable.setWidthPercentage(100);
		datatable.setHeaderRows(0);

		PdfPCell c = null;
		String room_type1 = "";
		String serial_no1 = "";
		String unit_no1 = "";
		String layer_no1 = "";
		String mark_no1 = "";
		String jianzhu_area1 = "";
		String jiesuan_area1 = "";
		String location_name1 = "";
		String master_name1 = "";

		String room_type2 = "";
		String serial_no2 = "";
		String unit_no2 = "";
		String layer_no2 = "";
		String mark_no2 = "";
		String jianzhu_area2 = "";
		String jiesuan_area2 = "";
		String location_name2 = "";
		String master_name2 = "";

		String reportYear = StringUtil.formatDate(new java.util.Date(), "yyyy");
		String reportMonth = StringUtil.formatDate(new java.util.Date(), "MM");
		String reportDay = StringUtil.formatDate(new java.util.Date(), "dd");

		String v = "";

		while (rs.next())
		{
			room_type1 = "";
			serial_no1 = "";
			unit_no1 = "";
			layer_no1 = "";
			mark_no1 = "";
			jianzhu_area1 = "";
			jiesuan_area1 = "";
			location_name1 = "";
			master_name1 = "";
		
			room_type2 = "";
			serial_no2 = "";
			unit_no2 = "";
			layer_no2 = "";
			mark_no2 = "";
			jianzhu_area2 = "";
			jiesuan_area2 = "";
			location_name2 = "";
			master_name2 = "";

			/*第一列*/
			if (!rs.isNull("room_type")) {		
				room_type1 = rs.getString("room_type");
				//anthony add 2010-10-9 在室型后增加“室”
				room_type1 = room_type1 + "室";
				
				room_type2 = room_type1;
			}
			if (!rs.isNull("serial_no")) {		
				serial_no1 = rs.getString("serial_no");
				serial_no2 = serial_no1;
			}
			if (!rs.isNull("unit_no")) {		
				unit_no1 = rs.getString("unit_no");
				unit_no2 = unit_no1;
			}
			if (!rs.isNull("layer_no")) {		
				layer_no1 = rs.getString("layer_no");
				layer_no2 = layer_no1;
			}
			if (!rs.isNull("mark_no")) {		
				mark_no1 = rs.getString("mark_no");
				//System.out.print("mark_no:"+mark_no1+":");
				if(mark_no1.indexOf('-')>0){
					mark_no1 = mark_no1.split("-")[1];
				}
				//System.out.println("mark_no:"+mark_no1);
				mark_no2 = mark_no1;
			}
			if (!rs.isNull("jianzhu_area")) {		
				jianzhu_area1 = rs.getString("jianzhu_area");
				jianzhu_area2 = jianzhu_area1;
			}
			if (!rs.isNull("jiesuan_area")) {		
				jiesuan_area1 = rs.getString("jiesuan_area");
				jiesuan_area2 = jiesuan_area1;
			}
			if (!rs.isNull("location_name")) {		
				location_name1 = rs.getString("location_name");
				location_name2 = location_name1;
			}
			if (!rs.isNull("master_name")) {		
				master_name1 = rs.getString("master_name");
				master_name2 = master_name1;
			}
			//anthony add begin
			if (!rs.isNull("jiu_date")) {	
				String jiu_date = new java.text.SimpleDateFormat("yyyy-M-d").format(rs.getDate("jiu_date"));
				//System.out.println("not null:"+jiu_date);
				reportYear = jiu_date.split("-")[0];
				reportMonth = jiu_date.split("-")[1];
				reportDay = jiu_date.split("-")[2];
			}else{
				//System.out.println("is null:");
			}
			
			//anthony add end

			/*第二列*/
			/**
			if(rs.next()){
					if (!rs.isNull("room_type")) {		
						room_type2 = rs.getString("room_type");
					}
					if (!rs.isNull("serial_no")) {		
						serial_no2 = rs.getString("serial_no");
					}
					if (!rs.isNull("unit_no")) {		
						unit_no2 = rs.getString("unit_no");
					}
					if (!rs.isNull("layer_no")) {		
						layer_no2 = rs.getString("layer_no");
					}
					if (!rs.isNull("mark_no")) {		
						mark_no2 = rs.getString("mark_no");
					}
					if (!rs.isNull("jianzhu_area")) {		
						jianzhu_area2 = rs.getString("jianzhu_area");
					}
					if (!rs.isNull("jiesuan_area")) {		
						jiesuan_area2 = rs.getString("jiesuan_area");
					}
					if (!rs.isNull("location_name")) {		
						location_name2 = rs.getString("location_name");
					}
					if (!rs.isNull("master_name")) {		
						master_name2 = rs.getString("master_name");
					}
			}*/
			
			/*第一行*/
			/* 几室 */
				v = room_type1;
				c = new PdfPCell( new Phrase( v , tblHeaderFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(4);
				c.setPadding(10);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	
			
			/*标题*/
			c = new PdfPCell(new Phrase("中    签    房    号", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(8);
			c.setHorizontalAlignment(Element.ALIGN_LEFT);
			datatable.addCell(c);

			/* 几室 */
				v = room_type2;
				c = new PdfPCell( new Phrase( v , tblHeaderFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(6);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	
			
			/*标题*/
			c = new PdfPCell(new Phrase("中    签    房    号", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(8);
			c.setHorizontalAlignment(Element.ALIGN_LEFT);
			datatable.addCell(c);

			/*第二行*/
			/*面积*/
			c = new PdfPCell(new Phrase("面积", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setPadding(8);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);
			/*建筑面积*/
				v = jianzhu_area1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
				c.setHorizontalAlignment(Element.ALIGN_CENTER);
				datatable.addCell(c);	

			c = new PdfPCell(new Phrase("㎡", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_LEFT);
			datatable.addCell(c);

			/*结算面积*/
			c = new PdfPCell(new Phrase("结算面积", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(4);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

				v = jiesuan_area1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
				c.setHorizontalAlignment(Element.ALIGN_CENTER);
				datatable.addCell(c);	


			c = new PdfPCell(new Phrase("㎡", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_LEFT);
			datatable.addCell(c);


			/*面积*/
			c = new PdfPCell(new Phrase("面积", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(4);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*建筑面积*/
				v = jianzhu_area2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
				c.setHorizontalAlignment(Element.ALIGN_CENTER);
				datatable.addCell(c);	

			c = new PdfPCell(new Phrase("㎡", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_LEFT);
			datatable.addCell(c);

			/*结算面积*/
			c = new PdfPCell(new Phrase("结算面积", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(4);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

				v = jiesuan_area2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
				c.setHorizontalAlignment(Element.ALIGN_CENTER);
				datatable.addCell(c);	


			c = new PdfPCell(new Phrase("㎡", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_LEFT);
			datatable.addCell(c);

			/*第三行*/
			/*姓名*/
			c = new PdfPCell(new Phrase("姓名", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setPadding(8);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*姓名*/
				v = master_name1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(3);
				c.setHorizontalAlignment(Element.ALIGN_LEFT);
				datatable.addCell(c);	

			/*小区名*/
				v = location_name1;
				//anthony modify begin
				//c = new PdfPCell( new Phrase( v , tblBodyFont ) );
				c = new PdfPCell( new Phrase( v , tblHeaderFont ) );
				//anthony modify end
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(5);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*小区*/
			c = new PdfPCell(new Phrase("小区", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*姓名*/
			c = new PdfPCell(new Phrase("姓名", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(4);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*姓名*/
				v = master_name2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(3);
				c.setHorizontalAlignment(Element.ALIGN_LEFT);
				datatable.addCell(c);	

			/*小区名*/
				v = location_name2;
				//anthony modify begin
				//c = new PdfPCell( new Phrase( v , tblBodyFont ) );
				c = new PdfPCell( new Phrase( v , tblHeaderFont ) );
				//anthony modify end
				
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(5);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*小区*/
			c = new PdfPCell(new Phrase("小区", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);


			/*第四行*/
			/*楼号*/
				v = serial_no1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
			c.setPadding(8);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*号楼*/
			c = new PdfPCell(new Phrase("号楼", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*单元*/
				v = unit_no1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(1);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*单元*/
			c = new PdfPCell(new Phrase("单元", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*层*/
				v = layer_no1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(1);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*层*/
			c = new PdfPCell(new Phrase("层", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*号*/
				v = mark_no1;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*号*/
			c = new PdfPCell(new Phrase("号", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);


			/*楼号*/
				v = serial_no2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(4);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*号楼*/
			c = new PdfPCell(new Phrase("号楼", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*单元*/
				v = unit_no2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(1);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*单元*/
			c = new PdfPCell(new Phrase("单元", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*层*/
				v = layer_no2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(1);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*层*/
			c = new PdfPCell(new Phrase("层", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);

			/*号*/
				v = mark_no2;
				c = new PdfPCell( new Phrase( v , tblBodyFont ) );
	    		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
				c.setColspan(2);
				c.setHorizontalAlignment(Element.ALIGN_RIGHT);
				datatable.addCell(c);	

			/*号*/
			c = new PdfPCell(new Phrase("号", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);


			/*第五行*/
			/*单位名称*/
			c = new PdfPCell(new Phrase("大连经济技术开发区动迁所", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(12);
			c.setPadding(8);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*单位名称*/
			c = new PdfPCell(new Phrase("大连经济技术开发区动迁所", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(14);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);
			
			/*第六行*/
			/*年*/
			c = new PdfPCell(new Phrase(reportYear, tblBodyFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(5);
			c.setPadding(8);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			c = new PdfPCell(new Phrase("年", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*月*/
			c = new PdfPCell(new Phrase(reportMonth, tblBodyFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			c = new PdfPCell(new Phrase("月", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*日*/
			c = new PdfPCell(new Phrase(reportDay, tblBodyFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			c = new PdfPCell(new Phrase("日", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*年*/
			c = new PdfPCell(new Phrase(reportYear, tblBodyFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(7);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			c = new PdfPCell(new Phrase("年", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*月*/
			c = new PdfPCell(new Phrase(reportMonth, tblBodyFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			c = new PdfPCell(new Phrase("月", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			/*日*/
			c = new PdfPCell(new Phrase(reportDay, tblBodyFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(2);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			c = new PdfPCell(new Phrase("日", tblHeaderFont ));
			//c.setGrayFill(0.95f);
			c.setBorder(Rectangle.NO_BORDER);
			c.setColspan(1);
			c.setHorizontalAlignment(Element.ALIGN_RIGHT);
			datatable.addCell(c);

			
			v = " ";
			c = new PdfPCell( new Phrase( v, tblBodyFont ) );
  		c.setBorder(Rectangle.NO_BORDER); /*0-NO_BORDER,1-TOP,2-BOTTOM*/
			c.setHorizontalAlignment(Element.ALIGN_CENTER);
			datatable.addCell(c);
	        datatable.completeRow();   		
			datatable.addCell(c);
	        datatable.completeRow();   		
			datatable.addCell(c);
	        datatable.completeRow();   		

		} 		
		
		return datatable;
		
	}

}
